import request from "../utils/request";
import { UserType, AddressType } from "../types/user";

export const userReg = (user: UserType) => {
  return request.post("/users", user);
};

export const userLogin = (user: UserType) => {
  return request.post("/login", user);
};

//新增购物车
export const cartAdd = (cartObj: any) => {
  return request.post("/classes/VueCart", cartObj);
};

export const cartGet = (userid: string) => {
  return request.get(`/classes/VueCart?where={"userid":"${userid}"}`);
};

//地址管理
export const addressPost = (addressObj: AddressType) => {
  return request.post("/classes/VueAddress", addressObj);
};

export const addressGet = (userid: string) => {
  return request.get(`/classes/VueAddress?where={"userid":"${userid}"}`);
};

export const addressPut = (objectId: string, addressObj: AddressType) => {
  return request.put(`/classes/VueAddress/${objectId}`, addressObj);
};
